package com.alisls.activiti.service.controller;

import com.alisls.activiti.service.req.ModelREQ;
import com.alisls.activiti.service.service.ModelService;
import com.alisls.activiti.service.util.Result;
import com.alisls.activiti.service.vo.ModelVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 模型管理
 *
 * @author Ke Wang
 */
@Api(tags = "模型管理")
@RestController
@RequestMapping("/model")
public class ModelController {

    @Resource
    private ModelService modelService;

    @ApiOperation(value = "模型分页查询")
    @PostMapping("/list")
    public Result page(@RequestBody ModelREQ modelREQ) {
        return Result.ok(modelService.page(modelREQ));
    }

    @ApiOperation(value = "保存一条模型数据")
    @PostMapping("/")
    public Result save(@RequestBody ModelVO modelVO) throws Exception {
        return Result.ok(modelService.save(modelVO));
    }

    @ApiOperation(value = "删除模型")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable String id) {
        return Result.ok(modelService.delete(id));
    }

    @ApiOperation(value = "通过模型标识部署模型")
    @PostMapping("/deploy/{modelId}")
    public Result deploy(@PathVariable String modelId) throws Exception{
        modelService.deploy(modelId);
        return Result.ok();
    }

}
